<?php
 include("recordmanager.php");
    if(! isset($_SESSION['sectors'])){
        session_start();
        retreiveGasType();
    }

$rowArray2 = $_SESSION['GasPriceNames'];

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Process Itinerary</title>
        <meta name="keywords" content="itinerary, list" />
        <meta name="description" content="This page provides a list of all itineraries" />
        <link href="css/default.css" rel="stylesheet" type="text/css" />
    </head>


    <body>
        <div id="wrapper">
            <?php include 'include/header.php'; ?>
          <div id="page">
                <div id="content">



                <h1>加油记录详单</h1>

                 <?php                   
                       if(isset($_REQUEST["confirmed"])){
                           $gasStationName;
                           $amount;
                           $gasType;
                           $price;
                           $time;
                           $mileage;
                            if(isset($_REQUEST["gasStationName"])){
                                $gasStationName = $_REQUEST["gasStationName"];
                            }
                            if(isset($_REQUEST["amount"])){
                                $amount = $_REQUEST["amount"];
                            }
                            if(isset($_REQUEST["gasType"])){
                                $gasType = $_REQUEST["gasType"];
                            }
                            if(isset($_REQUEST["price"])){
                                $price = $_REQUEST["price"];
                            }
                            if(isset($_REQUEST["time"])){
                                $time = $_REQUEST["time"];
                            }
                            if(isset($_REQUEST["mileage"])){
                                $mileage = $_REQUEST["mileage"];
                            }

                commitRecord($gasStationName,$amount,$gasType,$price,$time,$mileage);
                $IID=1;
                if($IID != -1){
//                        $_REQUEST["confirmed"]=null;
                       
                        echo "<p>加油记录提交成功<br>";    
                        echo "<br><br><a href='listrecords.php'>查询所有记录</a>";
                    }
                    else{
                        echo "<h2>Itinerary Rejected</h2>";
                        echo "<p>Your itinerary has been rejected.<br>";
                        echo "<p>There is a similiar itinerary present in our records with the same guest name, flight details and travel date.";
                        echo "<br><br><a href='listitinerary.php'>View All Itinerary</a>";
                    }
       
                 ?>                            
                <?php
                  }
                  else {
                ?>                  
                <form action="book.php">
                        <div id="UILabel">加油站</div><input class="form_tfield" type="text" name="gasStationName" value="" /><br></br>
                        <div id="UILabel">加油数量</div><input class="form_tfield" type="text" name="amount" value="" /><br></br>
                        <div id="UILabel">油品类型</div><select class="form_tfield" name="gasType"><br></br>
                            <?php                           
                                $count=count($rowArray2);
                                $default=$rowArray2[$count-1];
                                echo "<option selected value='".$default->get_GID()."'>".$default->get_Name()." ￥".$default->get_Price()."</option>";
                                for($index=$count-2;$index > -1;$index--){
                                        echo "<option value='".$rowArray2[$index]->get_GID()."'>".$rowArray2[$index]->get_Name()." ￥".$rowArray2[$index]->get_Price()."</option>";
                                }

                            ?>
                        </select>
                        <br></br>
                        <div id="UILabel">加油金额</div><input class="form_tfield" type="text" name="price" value="" /><br></br>
                        <div id="UILabel">里程</div><input class="form_tfield" type="text" name="mileage" value="" /><br></br>
                        <div id="UILabel">加油时间</div><input class="form_tfield" type="text" name="time" value="" /><br/>
                        <div id="note">
                            <p>输入格式为 yyyy-mm-dd HH:MM:SS</p>
                        </div>
                        <input type='hidden' name='confirmed' value='yes'/>
                        <input class="form_submitb" type="submit" value="提交" />
                </form>
                  <?php
                    }
                  ?>

                
             </div>
                <!-- end div#content -->
                <div id="sidebar">
                    <ul>
                        <?php include 'include/nav.php'; ?>
                        <!-- end navigation -->
                        <?php include 'include/updates.php'; ?>
                        <!-- end updates -->
                    </ul>
                </div>
                <!-- end div#sidebar -->
                <div style="clear: both; height: 1px"></div>
            </div>
            <?php include 'include/footer.php'; ?>
        </div>
        <!-- end div#wrapper -->
    </body>
</html>


